<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/1
 * Time: 10:47
 */

namespace app\flower\controller;
use cmf\controller\AdminBaseController;
use think\Db;
use app\flower\model\FlowerGuestpinglunModel;
class AdminGuestsController extends AdminBaseController
{
    /**
     * 用户评论展示页面
     */
   public function index(){
       $model = new FlowerGuestpinglunModel();
       $result = $model->where('deltime',0)->select();
       $this->assign('guests',$result);
       return $this->fetch();
   }

    /**
     * 用户评论添加页面
     */
    public function pinglunadd(){
       return $this->fetch('add');
    }

    /**
     * @return mixed
     * 添加内容
     */
    public function add(){
        $content = input('content');//内容
        $img = input('img');//内容
        $headerimg = input('headerimg');//内容
        $nickname = input('nickname');//内容
        $data['img'] = $img;
        $data['headimg'] = $headerimg;
        $data['nickname'] = $nickname;
        $data['content'] = $content;
        $data['dottime'] = time();
        $result = Db::name('flower_guestpinglun')->insert($data);
        if($result>0){
           $this->success('提交成功');
        }else{
            $this->success('提交失败');
        }
    }

    /**
     * 删除
     */
    public function delete(){
        $model = new FlowerGuestpinglunModel();
        $id = input('id');
        $data['deltime'] = time();
        $result = $model->where('id',$id)->update($data);
        if($result>0){
            $this->success('删除成功');
        }else{
            $this->success('删除失败');
        }
    }
}